package domain

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"market/internal/dao"
	"market/internal/model"
	"market/internal/repo"
	"mscoin-common/msdb"
)

// 货币coin的domain
type CoinDomain struct {
	CoinRepo repo.CoinRepo
}

func NewCoinDomain(db *msdb.MsDB) *CoinDomain {
	return &CoinDomain{
		CoinRepo: dao.NewCoinDao(db),
	}
}

/*
*
查询货币详情
*/
func (d *CoinDomain) FindByUnit(ctx context.Context, unit string) *model.Coin {
	coin, err := d.CoinRepo.FindByUnit(ctx, unit)
	if err != nil {
		logx.Error(err)
		return &model.Coin{}
	}
	return coin
}
